*************************************************************
*********Analysis based on original Ghana event data*********
*************************************************************
****************Analysis run using Stata 16******************
*************************************************************

*Note: This article uses three different datasets. To avoid repeatedly switching between datasets, the following coding is organized by datasets, rather than the order of appearance in the manuscript/online appendices.


*Packages needed
ssc install acreg, replace
ssc install coefplot, replace
ssc install imperfectiv, replace
ssc install sppack, replace


use "$root/Ghana_event.dta", clear


*Table 1 Original Ghana Data (Column 2) - information about other datasets (Columns 3-6) are gathered manually
table pre_bi if yr==2008
table pre_bi if yr==2012
table pre_bi if yr==2016


*Table 2
**Modle 1
logit pre_bi v33 v4 v5 v28 loggpop logdis i.yr i.gc i.ashanti i.north, cluster(cst)
**Modle 2
logit pre_bi v33 v4 v5 v28 loggpop logdis pev_last i.yr i.gc i.ashanti i.north, cluster(cst)


*Table 5
reg solidarity v33 v4 v5 v28 loggpop logdis i.yr i.gc i.ashanti i.north, cluster(cst)
reg solidarity v33 v4 v5 v28 loggpop logdis solidarity_last i.yr i.gc i.ashanti i.north, cluster(cst)


*************************************************************
*Appendix C 
*************************************************************

*Table C1
sum pre_bi
sum solidarity
sum v33
sum v4
sum v5
sum v28
sum loggpop
sum logdis
sum elf
sum incumbent
sum mal
sum new
sum logdist
sum logpop
sum logeco
sum urban


*Figure C2, panel a
hist v33, percent


*************************************************************
*Appendix D 
*************************************************************

*Table D1
**Modle 1
logit pre_bi v33 v4 v5 v28 loggpop logdis elf pev_last i.yr i.gc i.ashanti i.north, cluster(cst)
**Modle 2
logit pre_bi v33 v4 v5 v28 loggpop logdis incumbent pev_last i.yr i.gc i.ashanti i.north, cluster(cst)
**Modle 3
logit pre_bi v33 v4 v5 v28 loggpop logdis mal pev_last i.yr i.gc i.ashanti i.north, cluster(cst)
**Modle 4
logit pre_bi v33 v4 v5 v28 loggpop logdis new pev_last i.yr i.gc i.ashanti i.north, cluster(cst)
**Modle 5
logit pre_bi v33 v4 v5 v28 loggpop logdis logdist pev_last i.yr i.gc i.ashanti i.north, cluster(cst)
**Modle 6
logit pre_bi v33 v4 v5 v28 loggpop logdis logpop pev_last i.yr i.gc i.ashanti i.north, cluster(cst)
**Modle 7
logit pre_bi v33 v4 v5 v28 loggpop logdis logeco pev_last i.yr i.gc i.ashanti i.north, cluster(cst)
**Modle 8
logit pre_bi v33 v4 v5 v28 loggpop logdis urban pev_last i.yr i.gc i.ashanti i.north, cluster(cst)
**Modle 9
logit pre_bi v33 v4 v5 v28 loggpop logdis elf incumbent mal new logdist logpop logeco urban pev_last i.yr i.gc i.ashanti i.north, cluster(cst)


*Table D8
**Modle 1
reg solidarity v33 v4 v5 v28 loggpop logdis elf solidarity_last i.yr i.gc i.ashanti i.north, cluster(cst)
**Modle 2
reg solidarity v33 v4 v5 v28 loggpop logdis incumbent solidarity_last i.yr i.gc i.ashanti i.north, cluster(cst)
**Modle 3
reg solidarity v33 v4 v5 v28 loggpop logdis electric solidarity_last i.yr i.gc i.ashanti i.north, cluster(cst)
**Modle 4
reg solidarity v33 v4 v5 v28 loggpop logdis new solidarity_last i.yr i.gc i.ashanti i.north, cluster(cst)
**Modle 5
reg solidarity v33 v4 v5 v28 loggpop logdis lit solidarity_last i.yr i.gc i.ashanti i.north, cluster(cst)
**Modle 6
reg solidarity v33 v4 v5 v28 loggpop logdis logpop solidarity_last i.yr i.gc i.ashanti i.north, cluster(cst)
**Modle 7
reg solidarity v33 v4 v5 v28 loggpop logdis logeco solidarity_last i.yr i.gc i.ashanti i.north, cluster(cst)
**Modle 8
reg solidarity v33 v4 v5 v28 loggpop logdis urban solidarity_last i.yr i.gc i.ashanti i.north, cluster(cst)
**Modle 9
reg solidarity v33 v4 v5 v28 loggpop logdis elf incumbent electric new lit logpop logeco urban solidarity_last i.yr i.gc i.ashanti i.north, cluster(cst)


*Table D9
**Modle 1
reg winnershare v33 v4 v5 v28 loggpop logdis i.yr i.gc i.ashanti i.north, cluster(cst)
**Modle 2
reg winnershare v33 v4 v5 v28 loggpop logdis winnershare_last i.yr i.gc i.ashanti i.north, cluster(cst)


*Table D10
*This analysis is conducted on R. Please refer to the R script


*Table D12
**Model 3
logit pre_bi v33 v4 v5 v28 loggpop logdis malaria logeqt i.yr i.gc i.ashanti i.north, cluster(cst)
**Model 4
logit pre_bi v33 v4 v5 v28 loggpop logdis malaria logeqt pev_last i.yr i.gc i.ashanti i.north, cluster(cst)


*Table D13
**Model 4
logit pre_bi v33 v4 v5 v28 loggpop logdis elf incumbent mal new logdist logpop logeco urban pev_last i.yr i.gc i.ashanti i.north if npp==0 & ndc==0, cluster(cst)
**Model 5
logit pre_bi v33 v4 v5 v28 loggpop logdis elf incumbent mal new logdist logpop logeco urban pev_last i.yr i.gc i.ashanti i.north if solidarity_last>0.4440872, cluster(cst)


*Table D14
**DV: Risk of PEV
acreg pre_bi v33 v4 v5 v28 loggpop logdis pev_last i.yr i.gc i.ashanti i.north, spatial latitude(latitude) longitude(longitude) dist(100)
acreg pre_bi v33 v4 v5 v28 loggpop logdis pev_last i.yr i.gc i.ashanti i.north, spatial latitude(latitude) longitude(longitude) dist(50)
acreg pre_bi v33 v4 v5 v28 loggpop logdis pev_last i.yr i.gc i.ashanti i.north, spatial latitude(latitude) longitude(longitude) dist(25)
acreg pre_bi v33 v4 v5 v28 loggpop logdis pev_last i.yr i.gc i.ashanti i.north, spatial latitude(latitude) longitude(longitude) dist(10)
acreg pre_bi v33 v4 v5 v28 loggpop logdis pev_last i.yr i.gc i.ashanti i.north, spatial latitude(latitude) longitude(longitude) dist(5)
acreg pre_bi v33 v4 v5 v28 loggpop logdis pev_last i.yr i.gc i.ashanti i.north, spatial latitude(latitude) longitude(longitude) dist(1)


*Table D16
**Modle 1
logit pre_bi v33 i.north v4 v5 v28 loggpop logdis i.yr, cluster(cst)
**Modle 2
logit pre_bi v33 i.north v4 v5 v28 loggpop logdis pev_last i.yr, cluster(cst)


*************************************************************
*Appendix E 
*************************************************************

*Table E1 Original Ghana Data (Column 2) - information about other datasets (Columns 3-6) are gathered manually
egen casualty=total(deaths), by(yr)
tabulate casualty yr


*************************************************************
*Analysis based on ECAV & DECO
*************************************************************

import delimited "$root/Event_data_ECAV&DECO.csv", encoding(ISO-8859-9) clear 

*************************************************************
*Appendix C 
*************************************************************

*Figure C2, panel d & e
*panel d
hist v33, percent
*panel e
hist v33 if bricol==1, percent


*************************************************************
*Appendix D 
*************************************************************

*Table D2
**Model 1
logit ecav_bi v33 bri other v4 v5 v28 loggpop logdis i.year i.ccode, cluster(region)
**Model 2
logit ecav_bi v33 bri other v4 v5 v28 loggpop logdis elf logeco logdist logpop lagecav_b i.year i.ccode, cluster(region)
**Model 3
logit ecav_bi c.v33##i.bri c.v33##i.other v4 v5 v28 loggpop logdis i.year i.ccode, cluster(region)
**Model 4
logit ecav_bi c.v33##i.bri c.v33##i.other v4 v5 v28 loggpop logdis elf logeco logdist logpop lagecav_b i.year i.ccode, cluster(region)
**Model 5
logit ecav_bi v33 v4 v5 v28 loggpop logdis i.year i.ccode if bricol==1, cluster(region)
**Model 6
logit ecav_bi v33 v4 v5 v28 loggpop logdis elf logeco logdist logpop lagecav_b i.year i.ccode if bricol==1, cluster(region)
**Model 7
logit ecav_bi v33 v4 v5 v28 loggpop logdis i.year i.ccode if fran==1, cluster(region)
**Model 8
logit ecav_bi v33 v4 v5 v28 loggpop logdis elf logeco logdist logpop lagecav_b i.year i.ccode if francol==1, cluster(region)
**Model 9
nbreg ecav_count v33 v4 v5 v28 loggpop logdis i.year i.ccode if bricol==1, cluster(region)
**Model 10
nbreg ecav_count v33 v4 v5 v28 loggpop logdis i.year i.ccode if fran==1, cluster(region)


*Table D3
**Model 1
logit deco_bi v33 bri other v4 v5 v28 loggpop logdis i.year i.ccode, cluster(region)
**Model 2
logit deco_bi v33 bri other v4 v5 v28 loggpop logdis elf logeco logdist logpop lagdeco_b i.year i.ccode, cluster(region)
**Model 3
logit deco_bi c.v33##i.bri c.v33##i.other v4 v5 v28 loggpop logdis i.year i.ccode, cluster(region)
**Model 4
logit deco_bi c.v33##i.bri c.v33##i.other v4 v5 v28 loggpop logdis elf logeco logdist logpop lagdeco_b i.year i.ccode, cluster(region)
**Model 5
logit deco_bi v33 v4 v5 v28 loggpop logdis i.year i.ccode if bricol==1, cluster(region)
**Model 6
logit deco_bi v33 v4 v5 v28 loggpop logdis elf logeco logdist logpop lagdeco_b i.year i.ccode if bricol==1, cluster(region)
**Model 7
logit deco_bi v33 v4 v5 v28 loggpop logdis i.year i.ccode if fran==1, cluster(region)
**Model 8
logit deco_bi v33 v4 v5 v28 loggpop logdis  elf logeco logdist logpop lagdeco_b i.year i.ccode if fran==1, cluster(region)
**Model 9
nbreg deco_count v33 v4 v5 v28 loggpop logdis i.year i.ccode if bricol==1, cluster(region)
**Model 10
nbreg deco_count v33 v4 v5 v28 loggpop logdis i.year i.ccode if fran==1, cluster(region)


*************************************************************
*Analysis based on Afrobarometer data
*************************************************************

use "$root/Afrobarometer.dta", clear


*Table 3
**Model 1
ologit pev v33 bri other v4 v5 v28 logdis i.wafr i.round4 i.round5, cluster(ethnicity)
**Modle 2
ologit pev v33 bri other v4 v5 v28 logdis age poverty education gender rur news i.wafr i.round4 i.round5, cluster(ethnicity)
**Modle 3
ologit pev c.v33##i.bri c.v33##i.other v4 v5 v28 logdis i.wafr i.round4 i.round5, cluster(ethnicity)
**Modle 4
ologit pev c.v33##i.bri c.v33##i.other v4 v5 v28 logdis age poverty education gender rur news i.wafr i.round4 i.round5, cluster(ethnicity)
**Model 5
ologit pev v33 v4 v5 v28 loggpop logdis i.wafr  i.round4 i.round5 if bricol==1, cluster(ethnicity)
**Model 6
ologit pev v33 v4 v5 v28 loggpop logdis age poverty education gender rur news i.wafr i.round4 i.round5 if bricol==1, cluster(ethnicity)
**Model 7
ologit pev v33 v4 v5 v28 loggpop logdis i.wafr  i.round4 i.round5 if francol==1, cluster(ethnicity)
**Model 8
ologit pev v33 v4 v5 v28 loggpop logdis age poverty education gender rur news i.wafr i.round4 i.round5 if francol==1, cluster(ethnicity)


*Table 4
**Model 1
ivregress 2sls pev v4 v5 v28 loggpop logdis elevation cru_sprange i.wafr i.round4 i.round5 (v33=tsi) if bricol==1, cluster(ethnicity)
estat endogenous
estat firststage
***First-stage
reg v33 tsi v4 v5 v28 loggpop logdis elevation cru_sprange i.wafr i.round4 i.round5 if bricol==1&pev!=., cluster(ethnicity)

**Model 2
ivregress 2sls pev v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news i.wafr i.round4 i.round5 (v33=tsi) if bricol==1, cluster(ethnicity)
estat endogenous
estat firststage
***First-stage
reg v33 tsi v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news i.wafr i.round4 i.round5 if bricol==1&pev!=., cluster(ethnicity)


*Table 6
**Model 1
ologit elect_gift v33 v4 v5 v28 logdis loggpop age poverty education gender rur news i.wafr i.round3 i.round4 i.round5 if bricol==1, cluster(ethnicity)


*************************************************************
*Appendix B 
*************************************************************

*Table B1
**Model 1
ologit pev v33 v4 v5 v28 loggpop logdis age poverty education gender rur news i.wafr i.round4 i.round5 if bricol==1&nonmigrant==1, cluster(ethnicity)
**Model 2
ologit pev v33 v4 v5 v28 loggpop logdis age poverty education gender rur news i.wafr i.round4 i.round5 if bricol==1&nonmigrant==0, cluster(ethnicity)


*************************************************************
*Appendix C 
*************************************************************

*Table C2
sum pev
sum v33
sum v4
sum v5
sum v28
sum loggpop
sum logdis
sum white
sum ecovarsimple
sum logeb
sum v30
sum large_ani
sum womenpart
sum slavery
sum malaria
sum elect_gift
sum rally
sum age
sum poverty
sum education
sum gender
sum rur
sum news


*Figure C1
*panel a
hist pev
*panel b
hist pev if bricol==1
*panel c
hist pev if francol==1
*panel d
hist pev if bricol==0&francol==0


*Figure C2, panel b & c
*panel b
hist v33, percent
*panel c
hist v33 if bricol==1, percent


*************************************************************
*Appendix D 
*************************************************************

*Figure D1
ologit trust v33 v4 loggpop logdis large_ani v30 logeqt age poverty education gender rur news i.round4 i.round5, cluster(ethnicity)
estimates store trust_all

ologit trust v33 v4 loggpop logdis large_ani v30 logeqt age poverty education gender rur news i.round4 i.round5 if bri==1, cluster(ethnicity)
estimates store trust_b

ologit trust v33 v4 loggpop logdis large_ani v30 logeqt age poverty education gender rur news i.round4 i.round5 if fran==1, cluster(ethnicity)
estimates store trust_f

ologit corrupt v33 v4 loggpop logdis large_ani v30 logeqt age poverty education gender rur news i.wafr i.round4 i.round5, cluster(ethnicity)
estimates store corrupt_all

ologit corrupt v33 v4 loggpop logdis large_ani v30 logeqt age poverty education gender rur news i.wafr i.round4 i.round5 if bri==1, cluster(ethnicity)
estimates store corrupt_b

ologit corrupt v33 v4 loggpop logdis large_ani v30 logeqt age poverty education gender rur news i.wafr i.round4 i.round5 if fran==1, cluster(ethnicity)
estimates store corrupt_f

ologit perform v33 v4 loggpop logdis large_ani v30 logeqt age poverty education gender rur news i.wafr i.round4 i.round5, cluster(ethnicity)
estimates store perform_all

ologit perform v33 v4 loggpop logdis large_ani v30 logeqt age poverty education gender rur news i.wafr i.round4 i.round5 if bri==1, cluster(ethnicity)
estimates store perform_b

ologit perform v33 v4 loggpop logdis large_ani v30 logeqt age poverty education gender rur news i.wafr i.round4 i.round5 if fran==1, cluster(ethnicity)
estimates store perform_f

ologit influence v33 v4 v5 v28 logdis loggpop age poverty education gender rur news i.wafr i.round4 i.round5, cluster(ethnicity)
estimates store influence_all

ologit influence v33 v4 v5 v28 logdis loggpop age poverty education gender rur news i.wafr i.round4 i.round5 if bri==1, cluster(ethnicity)
estimates store influence_b

ologit influence v33 v4 v5 v28 logdis loggpop age poverty education gender rur news i.wafr i.round4 i.round5 if fran==1, cluster(ethnicity)
estimates store influence_f

ologit listen v33 v4 v5 v28 logdis loggpop age poverty education gender rur news i.wafr i.round4 i.round5, cluster(ethnicity)
estimates store listen_all

ologit listen v33 v4 v5 v28 logdis loggpop age poverty education gender rur news i.wafr i.round4 i.round5 if bri==1, cluster(ethnicity)
estimates store listen_b

ologit listen v33 v4 v5 v28 logdis loggpop age poverty education gender rur news i.wafr i.round4 i.round5 if fran==1, cluster(ethnicity)
estimates store listen_f

coefplot (trust_all,label(Trust TL)) (corrupt_all,label(TL Corruption)) (perform_all,label(TL Performance)) (influence_all,label(TL Influence)) (listen_all,label(TL Listen)), bylabel(All) || (trust_b)  (corrupt_b) (perform_b) (influence_b) (listen_b), bylabel(Anglophone)||(trust_f)  (corrupt_f) (perform_f) (influence_f) (listen_f), bylabel(Francoophone)||, rename() drop(v4 v5 v28 logdis loggpop large_ani v30 logeqt age poverty education gender rur news *.wafr *.round4 *.round5 _cons) xline(0) byopts(compact cols(1))


*Figure D2
ologit pev trust age poverty education gender rur news i.wafr i.round4 i.round5, cluster(ethnicity)
estimates store p_trust

ologit pev corrupt age poverty education gender rur news i.wafr i.round4 i.round5, cluster(ethnicity)
estimates store p_corrupt

ologit pev perform age poverty education gender rur news i.wafr i.round4 i.round5, cluster(ethnicity)
estimates store p_perform

ologit pev influence age poverty education gender rur news i.wafr i.round4 i.round5, cluster(ethnicity)
estimates store p_influence

ologit pev listen age poverty education gender rur news i.wafr i.round4 i.round5, cluster(ethnicity)
estimates store p_listen

ologit pev trust age poverty education gender rur news i.wafr i.round4 i.round5 if bri==1, cluster(ethnicity)
estimates store p_trust_b

ologit pev corrupt age poverty education gender rur news i.wafr i.round4 i.round5 if bri==1, cluster(ethnicity)
estimates store p_corrupt_b

ologit pev perform age poverty education gender rur news i.wafr i.round4 i.round5 if bri==1, cluster(ethnicity)
estimates store p_perform_b

ologit pev influence age poverty education gender rur news i.wafr i.round4 i.round5 if bri==1, cluster(ethnicity)
estimates store p_influence_b

ologit pev listen age poverty education gender rur news i.wafr i.round4 i.round5 if bri==1, cluster(ethnicity)
estimates store p_listen_b

ologit pev trust age poverty education gender rur news i.wafr i.round4 i.round5 if fran==1, cluster(ethnicity)
estimates store p_trust_f

ologit pev corrupt age poverty education gender rur news i.wafr i.round4 i.round5 if fran==1, cluster(ethnicity)
estimates store p_corrupt_f

ologit pev perform age poverty education gender rur news i.wafr i.round4 i.round5 if fran==1, cluster(ethnicity)
estimates store p_perform_f

ologit pev influence age poverty education gender rur news i.wafr i.round4 i.round5 if fran==1, cluster(ethnicity)
estimates store p_influence_f

ologit pev listen age poverty education gender rur news i.wafr i.round4 i.round5 if fran==1, cluster(ethnicity)
estimates store p_listen_f

coefplot (p_trust, nokey) (p_corrupt, nokey mcolor(navy) ciopts(color(navy))) (p_perform, nokey mcolor(navy) ciopts(color(navy))) (p_influence, nokey mcolor(navy) ciopts(color(navy))) (p_listen, nokey mcolor(navy) ciopts(color(navy))), bylabel(All) || (p_trust_b, nokey)  (p_corrupt_b, nokey) (p_perform_b, nokey) (p_influence_b, nokey) (p_listen_b, nokey), bylabel(Anglophone)||(p_trust_f, nokey)  (p_corrupt_f, nokey) (p_perform_f, nokey) (p_influence_f, nokey) (p_listen_f, nokey), bylabel(Francophone)||, drop(age poverty education gender rur news *.wafr *.round4 *.round5 _cons) xline(0) byopts(compact cols(1))


*Table D4
**Model 1
ologit pev v33 v4 v5 v28 loggpop logdis i.wafr  i.round4 i.round5 if bricol==1|ccode==22, cluster(ethnicity)
**Modle 2
ologit pev v33 v4 v5 v28 loggpop logdis age poverty education gender rur news i.wafr i.round4 i.round5 if bricol==1|ccode==22, cluster(ethnicity)
**Modle 3
ologit pev v33 v4 v5 v28 loggpop logdis i.wafr i.round4 i.round5 if bricol==0&francol==0, cluster(ethnicity)
**Modle 4
ologit pev v33 v4 v5 v28 loggpop logdis age poverty education gender rur news i.wafr i.round4 i.round5 if bricol==0&francol==0, cluster(ethnicity)
**Model 5
ologit pev v33 v4 v5 v28 loggpop logdis i.wafr i.round4 i.round5 if bricol==0&francol==0&ccode!=22, cluster(ethnicity)
**Model 6
ologit pev v33 v4 v5 v28 loggpop logdis age poverty education gender rur news i.wafr i.round4 i.round5 if bricol==0&francol==0&ccode!=22, cluster(ethnicity)


*Table D5
**Model 1
ivregress 2sls pev v4 v5 v28 loggpop logdis elevation cru_sprange i.wafr i.round4 i.round5 (v33=tsi) if bricol==1, cluster(ethnicity)
estat endogenous
estat firststage
***First-stage
reg v33 tsi v4 v5 v28 loggpop logdis elevation cru_sprange i.wafr i.round4 i.round5 if bricol==1&pev!=., cluster(ethnicity)
***Imperfect IV
imperfectiv pev v4 v5 v28 loggpop logdis elevation cru_sprange wafr round4 round5 (v33=tsi) if bricol==1, noas vce(cl ethnicity) bootstraps(100) seed(3.1415926)

**Model 2
ivregress 2sls pev v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news i.wafr i.round4 i.round5 (v33=tsi) if bricol==1, cluster(ethnicity)
estat endogenous
estat firststage
***First-stage
reg v33 tsi v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news i.wafr i.round4 i.round5 if bricol==1&pev!=., cluster(ethnicity)
***Imperfect IV
imperfectiv pev v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news wafr round4 round5 (v33=tsi) if bricol==1, noas vce(cl ethnicity) bootstraps(100) seed(3.1415926)


*Table D6
**Model 1
ivregress 2sls pev white v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news i.wafr i.round4 i.round5 (v33=tsi) if bricol==1, cluster(ethnicity)
estat endogenous
estat firststage
***First-stage
reg v33 tsi white v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news i.wafr i.round4 i.round5 if bricol==1&pev!=., cluster(ethnicity)
***Imperfect IV
imperfectiv pev white v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news wafr round4 round5 (v33=tsi) if bricol==1, noas vce(cl ethnicity) bootstraps(100) seed(3.1415926)

**Model 2
ivregress 2sls pev ecovarsimple v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news i.wafr i.round4 i.round5 (v33=tsi) if bricol==1, cluster(ethnicity)
estat endogenous
estat firststage
***First-stage
reg v33 tsi ecovarsimple v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news i.wafr i.round4 i.round5 if bricol==1&pev!=., cluster(ethnicity)
***Imperfect IV
imperfectiv pev ecovarsimple v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news wafr round4 round5 (v33=tsi) if bricol==1, noas vce(cl ethnicity) bootstraps(100) seed(3.1415926)

**Model 3
ivregress 2sls pev logeb v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news i.wafr i.round4 i.round5 (v33=tsi) if bricol==1, cluster(ethnicity)
estat endogenous
estat firststage
***First-stage
reg v33 tsi logeb v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news i.wafr i.round4 i.round5 if bricol==1&pev!=., cluster(ethnicity)
***Imperfect IV
imperfectiv pev logeb v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news wafr round4 round5 (v33=tsi) if bricol==1, noas vce(cl ethnicity) bootstraps(100) seed(3.1415926)

**Model 4
ivregress 2sls pev v30 v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news i.wafr i.round4 i.round5 (v33=tsi) if bricol==1, cluster(ethnicity)
estat endogenous
estat firststage
***First-stage
reg v33 tsi v30 v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news i.wafr i.round4 i.round5 if bricol==1&pev!=., cluster(ethnicity)
***Imperfect IV
imperfectiv pev v30 v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news wafr round4 round5 (v33=tsi) if bricol==1, noas vce(cl ethnicity) bootstraps(100) seed(3.1415926)

**Model 5
ivregress 2sls pev large_ani v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news i.wafr i.round4 i.round5 (v33=tsi) if bricol==1, cluster(ethnicity)
estat endogenous
estat firststage
***First-stage
reg v33 tsi large_ani v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news i.wafr i.round4 i.round5 if bricol==1&pev!=., cluster(ethnicity)
***Imperfect IV
imperfectiv pev large_ani v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news wafr round4 round5 (v33=tsi) if bricol==1, noas vce(cl ethnicity) bootstraps(100) seed(3.1415926)

**Model 6
ivregress 2sls pev womenpart v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news i.wafr i.round4 i.round5 (v33=tsi) if bricol==1, cluster(ethnicity)
estat endogenous
estat firststage
***First-stage
reg v33 tsi womenpart v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news i.wafr i.round4 i.round5 if bricol==1&pev!=., cluster(ethnicity)
***Imperfect IV
imperfectiv pev womenpart v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news wafr round4 round5 (v33=tsi) if bricol==1, noas vce(cl ethnicity) bootstraps(100) seed(3.1415926)

**Model 7
ivregress 2sls pev slavery v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news i.wafr i.round4 i.round5 (v33=tsi) if bricol==1, cluster(ethnicity)
estat endogenous
estat firststage
***First-stage
reg v33 tsi slavery v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news i.wafr i.round4 i.round5 if bricol==1&pev!=., cluster(ethnicity)
***Imperfect IV
imperfectiv pev slavery v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news wafr round4 round5 (v33=tsi) if bricol==1, noas ncorr vce(cl ethnicity) bootstraps(100) seed(3.1415926)

**Model 8
ivregress 2sls pev malaria v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news i.wafr i.round4 i.round5 (v33=tsi) if bricol==1, cluster(ethnicity)
estat endogenous
estat firststage
***First-stage
reg v33 tsi malaria v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news i.wafr i.round4 i.round5 if bricol==1&pev!=., cluster(ethnicity)
***Imperfect IV
imperfectiv pev malaria v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news wafr round4 round5 (v33=tsi) if bricol==1, noas ncorr vce(cl ethnicity) bootstraps(100) seed(3.1415926)


*Table D7
**Model 1
preserve 
duplicates report longitude latitude, inspect
duplicates tag longitude latitude, gen(tag)
sum tag

gen latitude_r=latitude
gen longitude_r=longitude
set seed 31415
gen double shuffle1 = runiform(-0.1,0.1)
set seed 14142
gen double shuffle2 = runiform(-0.1,0.1)
replace longitude_r = longitude +shuffle1 if tag>0
replace latitude_r = latitude +shuffle2 if tag>0
drop if latitude==.
drop if bricol==0
drop if v33==.
drop if tsi==.
drop if pev==.
drop if v28==.
spset, clear
gen _ID=_n
spset _ID, coord(longitude_r latitude_r) 
spset, modify coordsys(latlong, kilometers)
duplicates report longitude_r latitude_r, inspect
duplicates tag longitude_r latitude_r, gen(tag1)
drop if tag1>0

spmat idistance W _CX _CY, id(_ID) replace
spivreg pev v4 v5 v28 loggpop logdis elevation cru_sprange i.wafr i.round4 i.round5 (v33=tsi) if bricol==1, id(_ID) dlmat(W) heteroskedastic 
spreg gs2sls v33 tsi v4 v5 v28 loggpop logdis elevation cru_sprange wafr round4 round5 if bricol==1, id(_ID) dlmat(W) heteroskedastic
restore

**Model 2
preserve 
duplicates report longitude latitude, inspect
duplicates tag longitude latitude, gen(tag)
sum tag

gen latitude_r=latitude
gen longitude_r=longitude
set seed 31415
gen double shuffle1 = runiform(-0.1,0.1)
set seed 14142
gen double shuffle2 = runiform(-0.1,0.1)
replace longitude_r = longitude +shuffle1 if tag>0
replace latitude_r = latitude +shuffle2 if tag>0
drop if latitude==.
drop if bricol==0
drop if v33==.
drop if tsi==.
drop if pev==.
drop if v28==.
spset, clear
gen _ID=_n
spset _ID, coord(longitude_r latitude_r) 
spset, modify coordsys(latlong, kilometers)
duplicates report longitude_r latitude_r, inspect
duplicates tag longitude_r latitude_r, gen(tag1)
drop if tag1>0
drop if age==.
drop if poverty==.
drop if education==.
drop if news==.
spmat idistance W1 _CX _CY, id(_ID) replace
spivreg pev v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news i.wafr i.round4 i.round5 (v33=tsi) if bricol==1, id(_ID) dlmat(W1) heteroskedastic
spreg gs2sls v33 tsi v4 v5 v28 loggpop logdis elevation cru_sprange age poverty education gender rur news wafr round4 round5 if bricol==1, id(_ID) dlmat(W1) heteroskedastic
restore


*Table D11
**Model 1
ologit elect_gift v33 bricol other v4 v5 v28 logdis loggpop age poverty education gender rur news i.wafr i.round3 i.round4 i.round5, cluster(ethnicity)
**Model 2
ologit elect_gift c.v33##c.bricol c.v33##c.other v4 v5 v28 logdis loggpop age poverty education gender rur news i.wafr i.round3 i.round4 i.round5, cluster(ethnicity)
**Model 3
ologit elect_gift v33 v4 v5 v28 logdis loggpop age poverty education gender rur news i.wafr i.round3 i.round4 i.round5 if bricol==1, cluster(ethnicity)
**Model 4
ologit elect_gift v33 v4 v5 v28 logdis loggpop age poverty education gender rur news i.wafr i.round3 i.round4 i.round5 if francol==1, cluster(ethnicity)
**Model 5
logit rally v33 bricol other v4 v5 v28 logdis loggpop age poverty education gender rur news i.wafr i.round3 i.round4 i.round5, cluster(ethnicity)
**Model 6
logit rally c.v33##c.bricol c.v33##c.other v4 v5 v28 logdis loggpop age poverty education gender rur news i.wafr i.round3 i.round4 i.round5, cluster(ethnicity)
**Model 7
logit rally v33 v4 v5 v28 logdis loggpop age poverty education gender rur news i.wafr i.round3 i.round4 i.round5 if bricol==1, cluster(ethnicity)
**Model 8
logit rally v33 v4 v5 v28 logdis loggpop age poverty education gender rur news i.wafr i.round3 i.round4 i.round5 if francol==1, cluster(ethnicity)


*Table D12
**Model 1
ologit pev v33 v4 v5 v28 loggpop logdis malaria logeqt i.wafr i.round4 i.round5 if bricol==1, cluster(ethnicity)
**Model 2
ologit pev v33 v4 v5 v28 loggpop logdis malaria logeqt age poverty education gender rur news i.wafr i.round4 i.round5 if bricol==1, cluster(ethnicity)


*Table D13
**Model 1
ologit pev v33 v4 v5 v28 loggpop logdis age poverty education gender rur news i.wafr i.round4 i.round5 if bricol==1 & ccode!=30 & ccode!=33 & ccode!=35, cluster(ethnicity)
**Model 2
ologit pev v33 v4 v5 v28 loggpop logdis age poverty education gender rur news i.wafr i.round4 i.round5 if bricol==1 & ccode!=3 & ccode!=27 & ccode!=14, cluster(ethnicity)
**Model 3
ologit pev v33 v4 v5 v28 loggpop logdis age poverty education gender rur news i.wafr i.round4 i.round5 if bricol==1 & ccode!=11, cluster(ethnicity)


*Table D14
**DV: Fear of PEV
preserve
drop if round3==1
acreg pev v33 v4 v5 v28 loggpop logdis i.wafr i.round4 i.round5 if bricol==1, spatial latitude(latitude) longitude(longitude) dist(100)
acreg pev v33 v4 v5 v28 loggpop logdis i.wafr i.round4 i.round5 if bricol==1, spatial latitude(latitude) longitude(longitude) dist(50)
acreg pev v33 v4 v5 v28 loggpop logdis i.wafr i.round4 i.round5 if bricol==1, spatial latitude(latitude) longitude(longitude) dist(25)
acreg pev v33 v4 v5 v28 loggpop logdis i.wafr i.round4 i.round5 if bricol==1, spatial latitude(latitude) longitude(longitude) dist(10)
acreg pev v33 v4 v5 v28 loggpop logdis i.wafr i.round4 i.round5 if bricol==1, spatial latitude(latitude) longitude(longitude) dist(5)
acreg pev v33 v4 v5 v28 loggpop logdis i.wafr i.round4 i.round5 if bricol==1, spatial latitude(latitude) longitude(longitude) dist(1)
restore


*Table D15
**Model 1
ologit pev v33 majority v4 v5 v28 loggpop logdis i.wafr i.round4 i.round5 if bricol==1, cluster(ethnicity)
**Model 2
ologit pev v33 majority v4 v5 v28 loggpop logdis age poverty education gender rur news i.wafr i.round4 i.round5 if bricol==1, cluster(ethnicity)


